package com.yic.module.device.dal.mysql.receive;

import java.util.*;

import com.yic.framework.common.pojo.PageResult;
import com.yic.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.yic.framework.mybatis.core.mapper.BaseMapperX;
import com.yic.module.device.dal.dataobject.receive.ReceiveDO;
import org.apache.ibatis.annotations.Mapper;
import com.yic.module.device.controller.admin.receive.vo.*;

/**
 * 领用申请 Mapper
 *
 * @author 系统管理员
 */
@Mapper
public interface ReceiveMapper extends BaseMapperX<ReceiveDO> {

    default PageResult<ReceiveDO> selectPage(ReceivePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ReceiveDO>()
                .eqIfPresent(ReceiveDO::getCode, reqVO.getCode())
                .eqIfPresent(ReceiveDO::getApprove, reqVO.getApprove())
                .eqIfPresent(ReceiveDO::getDeviceId, reqVO.getDeviceId())
                .betweenIfPresent(ReceiveDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ReceiveDO::getId));
    }

    default List<ReceiveDO> selectList(ReceiveExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<ReceiveDO>()
                .eqIfPresent(ReceiveDO::getCode, reqVO.getCode())
                .eqIfPresent(ReceiveDO::getApprove, reqVO.getApprove())
                .eqIfPresent(ReceiveDO::getDeviceId, reqVO.getDeviceId())
                .betweenIfPresent(ReceiveDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ReceiveDO::getId));
    }

    default ReceiveDO selectByCode(String code) {
        return selectOne(new LambdaQueryWrapperX<ReceiveDO>()
                .eq(ReceiveDO::getCode, code));
    }
}
